package com.gzs.zhdj.controller;

import com.gzs.zhdj.constant.MessageConstant;
import com.gzs.zhdj.context.BaseContext;
import com.gzs.zhdj.domain.dto.PasswordEditDto;
import com.gzs.zhdj.domain.entity.PartyMember;
import com.gzs.zhdj.service.PartyMemberService;
import com.gzs.zhdj.utils.AliOssUtil;
import com.gzs.zhdj.utils.CommonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;



@Slf4j
@RestController
@RequestMapping("/partymember")
public class PartyMemberController {
    @Autowired
    PartyMemberService partyMemberService;

    @GetMapping("/selfinfo")
    public CommonResponse getPartyMember() {
        PartyMember partyMember = partyMemberService.getSelfInfo();
        return CommonResponse.ok(partyMember);
    }

    @PutMapping("updateselfinof")
    public CommonResponse update(@RequestBody PartyMember partyMember){
        log.info("修改党员信息, partyMember: {}", partyMember);
        partyMemberService.updateSelfInof(partyMember);
        return CommonResponse.ok();
    }

    @PutMapping("/updatepassword")
    public CommonResponse updatepassword(@RequestBody PasswordEditDto passwordEditDto){
        log.info("修改密码, passwordEditDto: {}", passwordEditDto);
        partyMemberService.updatePassword(passwordEditDto);
        return CommonResponse.ok();
    }
    @PostMapping("/upload")
    public CommonResponse upload(MultipartFile image){
        partyMemberService.upload(image);
        return CommonResponse.ok();
    }
}
